<?php if($pu == 'pu'):?>
    <?php foreach($data as $v):?>
    <tr>
        <td><img src="/<?php echo cutUrl($v['avatar'],80,40)?>" alt=""></td>
        <td style="line-height: 40px"><?php echo $v['nicname'] ? $v['nicname'] : $v['username'] ?></td>
        <td style="line-height: 40px"><?php echo $v['content']?></td>
        <td style="line-height: 40px"><?php echo $v['like']?></td>
        <td style="line-height: 40px"><?php echo $v['create_time']?></td>
        <td>

            <a href="javascript:;" data-id="<?php echo $v['id']?>" class="btn btn-danger btn-xs delete">删除</a>

        </td>
    </tr>
    <?php endforeach;?>
<?php else:?>
    <table class="table table-hover" id="comment-lists">
        <tr>
            <th style="border:none;">用户头像</th>
            <th style="border:none;">评论用户</th>
            <th style="border:none;">评论内容</th>
            <th style="border:none;">点赞数量</th>
            <th style="border:none;">评论时间</th>
            <th style="border:none;">操作</th>
        </tr>
        <?php foreach($data as $v):?>
        <tr>
            <td><img src="/<?php echo cutUrl($v['avatar'],80,40)?>" alt=""></td>
            <td style="line-height: 40px"><?php echo $v['nicname'] ? $v['nicname'] : $v['username'] ?></td>
            <td style="line-height: 40px"><?php echo $v['content']?></td>
            <td style="line-height: 40px"><?php echo $v['like']?></td>
            <td style="line-height: 40px"><?php echo $v['create_time']?></td>
            <td>

                <a href="javascript:;" data-id="<?php echo $v['id']?>" class="btn btn-danger btn-xs delete">删除</a>

            </td>
        </tr>
        <?php endforeach;?>
    </table>
    <script>

        $(function(){

            var page = 2;

            var id = '<?php echo $special_id?>';

            var total = <?php echo $total?>;

            var nums = <?php echo $nums?>;

            var $comment_lists = $('#comment-lists').parent();
            //选项卡
            $comment_lists.scroll(function(){

                if (($comment_lists.height()) - ($comment_lists.scrollTop()) < 20) {

                    if(page <= Math.ceil(total / nums)){

                        var lay = layer.load();

                        $.post('<?php echo U("Admin/Special/Index/commentLists")?>',{'id':id,'pu':'pu','page':page},function(result){

                            layer.close(lay);

                            if ( result ) {

                                $('tbody',$comment_lists).append(result);

                            }


                        });

                        page++;
                    }

                }

            });

            //删除一条评论
            $('#comment-lists').undelegate('.delete','click');
            $('#comment-lists').delegate('.delete','click',function(){

                var _this = $(this);

                var id = $(this).data('id');

                layer.msg('确定要删除吗?删除之后不可恢复!',{
                            time: 0 //不自动关闭
                            ,btn: ['删除', '取消']
                            ,yes: function(index){

                                layer.close(index);

                                $.post('<?php echo U("Admin/Special/Index/deleteComment")?>',{'id':id},function(result){

                                    showMessage(result.msg,result.code,'','',2000);

                                    if(result.code == 200) {

                                        _this
                                                .parent()
                                                .parent()
                                                .fadeOut(200,function(){

                                                    $(this).remove();

                                                })

                                    }

                                })

                            }
                        }
                );

            });

        });

    </script>
<?php endif;?>